var fs = require("fs");

//创建流
var ws = fs.createWriteStream("text2.txt");

//打开和关闭的监听，只使用一次
ws.once("open", function() {
    console.log("流打开了");
});
ws.once("close", function() {
    console.log("流关闭了");
});

//写
ws.write("流式文件写入\n");
ws.write("亮仔\n");
ws.write("有鱼\n");
ws.write("我");

//关闭流
ws.end();//ws.close()
